package com.ccc.oa.common.core.common;

import com.ccc.oa.common.core.constants.ConmmonConstants;

/**
 * --- 代码敲对！ ---
 *
 * @author CCCccc
 * @create 2025/10/10
 * 备注：返回结果类(R类)
 */
public class R {
    private int code;
    private String msg;
    private Object data;

    private R() {
    }

    public static R success() {
        R r = new R();
        r.setCode(ConmmonConstants.SUCCESS);
        r.setMsg("成功");
        return r;
    }

    public static R success(Object data) {
        R r = new R();
        r.setCode(ConmmonConstants.SUCCESS);
        r.setMsg("成功");
        r.setData(data);
        return r;
    }

    public static R success(String msg,Object data) {
        R r = new R();
        r.setCode(ConmmonConstants.SUCCESS);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }


    public static R fail() {
        R r = new R();
        r.setCode(ConmmonConstants.FAIL);
        r.setMsg("失败");
        return r;
    }

    public static R fail(String msg) {
        R r = new R();
        r.setCode(ConmmonConstants.FAIL);
        r.setMsg(msg);
        return r;
    }

    public static R fail(int code, String msg) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
